package mine.reflect;

import java.lang.reflect.Field;

/**
 * Created by james on 16/1/28.
 */
public class AccessibleTest {
    public static void main(String[] args) {
        try {
            Class clazz = Class.forName("test.reflect.Accessible");
            Accessible at = null;
            at = new Accessible();
            at.setId(1);
            at.setName("AT");
            for (Field f : clazz.getDeclaredFields()) {
//                f.setAccessible(true);//AccessibleTest类中的成员变量为private,故必须进行此操作
                System.out.println(f.get(at));//获取当前对象中当前Field的value
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
